import request from '@/utils/request'

// 查询优化包进程管理列表
export function listPackage(query) {
  return request({
    url: '/optimize/package/list',
    method: 'get',
    params: query
  })
}

// 查询优化包进程管理列表
export function listShortPackage(query) {
  return request({
    url: '/optimize/package/listShort',
    method: 'get',
    params: query
  })
}



// 查询预优化列表
export function preListPackage(query) {
  return request({
    url: '/optimize/package/preList',
    method: 'get',
    params: query
  })
}

// 预优化直接转正式优化
export function transformPackage(id) {
  return request({
    url: '/optimize/package/transform/' + id,
    method: 'get'
  })
}

export function queuePackage(query) {
  return request({
    url: '/optimize/package/queue',
    method: 'get',
    params: query
  })
}

export function queryOrderIds(id) {
  return request({
    url: '/optimize/package/queryOrderIds/' + id,
    method: 'get'
  })
}

export function queryPlates(id) {
  return request({
    url: '/optimize/package/queryPlates/' + id,
    method: 'get'
  })
}

export function querySameOrderPackage(id) {
  return request({
    url: '/optimize/package/querySameOrderPackage/' + id,
    method: 'get'
  })
}

export function checkRunning() {
  return request({
    url: '/optimize/package/running',
    method: 'get'
  })
}

// 查询优化包进程管理详细
export function getPackage(id) {
  return request({
    url: '/optimize/package/' + id,
    method: 'get'
  })
}

//获取已经确认下发的优化包列表
export function getConfirmedPackageList(query) {
  return request({
    url: '/optimize/package/confirmList',
    method: 'get',
    params: query
  })
}

//确认下发
export function confirmOptimize(id) {
  return request({
    url: '/optimize/package/confirmOptimize/' + id,
    method: 'get'
  })
}

// 导出优化包下发代码
export function exportOpt(id) {
  return request({
    url: '/optimize/package/export/opt/' + id,
    method: 'get'
  })
}

// 导出优化包排版
export function exportPdf(id) {
  return request({
    url: '/optimize/package/export/pdf/' + id,
    method: 'get'
  })
}

//获取重新优化参数
export function getReoptimizeParams(id) {
  return request({
    url: '/optimize/package/reOptimize/' + id,
    method: 'get'
  })
}

//根据参数导出pdf
export function exportpdfDetail(id,type,direction,version) {
  let url = '/optimize/package/export/pdfDetail?id=' + id;

  if(type){
    url += '&type=' + type;
  }
  if(direction){
    url += '&direction=' + direction;
  }
  if(version){
    url += '&version=' + version;
  }
  return request({
    url: url,
    method: 'get'
  })
}

export function getPackageCountWithOrderId(orderId) {
  return request({
    url: '/optimize/package/count/orderId/' + orderId,
    method: 'get'
  })
}

//获取显示的pdf二进制流
export function exportPdfShow(id,type,direction,version){
  let url = '/optimize/package/export/pdfShow?id=' + id;
  if(type){
    url += '&type=' + type;
  }
  if(direction){
    url += '&direction=' + direction;
  }
  if(version){
    url += '&version=' + version;
  }
  return request({
    url: url,
    method: 'get'
  })
}

//根据参数导出opt
export function exportoptDetail(id,type) {
  let url = '/optimize/package/export/optDetail?id=' + id;
  if(type){
    url += '&type=' + type;
  }
  return request({
    url: url,
    method: 'get'
  })
}


// 新增优化包进程管理
export function addPackage(data) {
  return request({
    url: '/optimize/package',
    method: 'post',
    data: data
  })
}



// 修改优化包进程管理
export function updatePackage(data) {
  return request({
    url: '/optimize/package',
    method: 'put',
    data: data
  })
}

export function reoptimize(id) {
  return request({
    url: '/optimize/package/reoptimize/' + id,
    method: 'get'
  })
}

// 删除优化包进程管理
export function delPackage(id) {
  return request({
    url: '/optimize/package/' + id,
    method: 'delete'
  })
}

// 添加尾片
export function addTailPlate(id, data) {
  return request({
    url: '/optimize/package/addTailPlate/' + id,
    method: 'post',
    data: data
  })
}

